home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-06 / sc3x00.zip / GETOBDSK.C < prev    next >
Text File  |  1992-08-18  |  5KB  |  107 lines

  1. //   ╔════════════════════════════════════════════════════════════════════╗
  2. //   ║                                                                    ║
  3. //   ║ module:      getobdsk.c                                            ║
  4. //   ║ abstract:    This module shows how to make 3.x system calls using  ║
  5. //   ║              the F2 Shell Interface.  Obviously, it requires the   ║
  6. //   ║              NetWare Shell.                                        ║
  7. //   ║                                                                    ║
  8. //   ║ environment: NetWare 3.x v3.11                                     ║
  9. //   ║              Borland C 3.0                                         ║
  10. //   ║                                                                    ║
  11. //   ║  This software is provided as is and carries no warranty           ║
  12. //   ║  whatsoever.  Novell disclaims and excludes any and all implied    ║
  13. //   ║  warranties of merchantability, title and fitness for a particular ║
  14. //   ║  purpose.  Novell does not warrant that the software will satisfy  ║
  15. //   ║  your requirements or that the software is without defect or error ║
  16. //   ║  or that operation of the software will be uninterrupted.  You are ║
  17. //   ║  using the software at your risk.  The software is not a product   ║
  18. //   ║  of Novell, Inc. or any of subsidiaries.                           ║
  19. //   ╚════════════════════════════════════════════════════════════════════╝
  20.  
  21. #include <stdio.h>
  22. #include <string.h>
  23. #include <stdlib.h>
  24. #include <dos.h>
  25.  
  26. #include "nwsys.h"
  27.  
  28. //
  29. //  First of all, we define the request and reply structures which are
  30. //  needed for the GetBinderyObjectID API call.  These structures are
  31. //  layed out according to the System Call documentation.
  32. //
  33.  
  34. struct  {
  35.     WORD    sflen;          // length of the structure.  This is 6 + 'onlen'
  36.     BYTE    sfcode;         // the subfunction code, in our case 53.
  37.     WORD    otype;          // object type (hi-lo)
  38.     BYTE    onlen;          // length of name (below)
  39.     BYTE    oname[48];      // name (doesn't need to be ASCIIZ)
  40. }GETOBJRequest;
  41.  
  42. struct  {
  43.     LONG    oid;            // the object ID returned (hi-lo)
  44.     WORD    otype;          // the object type returned (hi-lo)
  45.     BYTE    oname[48];      // the object name returned (ASCIIZ)
  46. }GETOBJReply;
  47.  
  48. //  First of all, we define the request and reply structures which are
  49. //  needed for the GetObjectDiskUsageAndRestriction API call.  These
  50. //  structures are layed out according to the System Call documentation.
  51. //
  52.  
  53. struct  {
  54.     WORD    sflen;          // length of the structure.  This is 6 + 'onlen'
  55.     BYTE    sfcode;         // the subfunction code, in our case 41.
  56.     BYTE    volumeNumber;   // length of name (below)
  57.     LONG    oid;            // object for which information is to be returned
  58. }GETOBDSKRequest;
  59.  
  60. struct  {
  61.     LONG    restriction;    //  Restriction on object for specified volume
  62.     LONG    inUse;          //  Actual space in use by Object
  63. }GETOBDSKReply;
  64.  
  65. //
  66. //  This is the main program.  The purpose is to make the GetBinderyObjectID
  67. //  API call to illustrate making system calls using the F2 interface.
  68. //
  69.  
  70. void main(int argc, char *argv[])
  71. {
  72.     int     cc;
  73.     int     length;
  74.  
  75.     if(argc!=4){printf("usage: GETOBDSK objectName ObjectType VolumeNumber\n");exit(1);}
  76.    //
  77.    //  Build the request buffer
  78.    //
  79.    GETOBJRequest.sfcode = 53;                        // subfunction code
  80.    GETOBJRequest.otype  = WordSwap(atoi(argv[2]));   // object type
  81.    GETOBJRequest.onlen  = strlen(argv[1]);           // object name length
  82.    GETOBJRequest.sflen  = WordSwap(6+GETOBJRequest.onlen); // length of this request
  83.    strcpy(GETOBJRequest.oname,argv[1]);              // object name
  84.  
  85.    cc = NWSystemCall(23,&GETOBJRequest,sizeof GETOBJRequest,&GETOBJReply,sizeof GETOBJReply);
  86.  
  87.    printf("Function returned:    %03d--%#02x\n",cc,cc);
  88.    if( cc == 0 ){
  89.        printf("Object id returned:   %#010lx\n",DWordSwap(GETOBJReply.oid));
  90.        printf("Object type returned: %#06x\n",WordSwap(GETOBJReply.otype));
  91.        printf("Object name returned: %s\n",GETOBJReply.oname);
  92.    }
  93.    //
  94.    //  Build the request buffer for restriction call
  95.    //
  96.    GETOBDSKRequest.sflen = sizeof GETOBDSKRequest;
  97.    GETOBDSKRequest.sfcode = 41;                       // subfunction code
  98.    GETOBDSKRequest.volumeNumber=atoi(argv[3]);
  99.    GETOBDSKRequest.oid=GETOBJReply.oid;
  100.    cc = NWSystemCall(22,&GETOBDSKRequest,sizeof GETOBDSKRequest,&GETOBDSKReply,sizeof GETOBDSKReply);
  101.    printf("Function returned:    %03d--%#02x\n",cc,cc);
  102.    if( cc == 0 ) {
  103.        printf("Restriction:          %8ld\n",GETOBDSKReply.restriction);
  104.        printf("In Use:                 %8ld\n",GETOBDSKReply.inUse);
  105.    }
  106. }
  107.